Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.fileset.fileFilter: init #260265

Merged
merged 1 commit into from
Oct 24, 2023
Merged

lib.fileset.fileFilter: init #260265

merged 1 commit into from
Oct 24, 2023

Conversation

infinisil
Copy link
Member

Description of changes

This is another split off from the WIP fileset combinators PR.

This adds one function:

  • lib.fileset.fileFilter :: (Attrs -> Bool) -> FileSet -> FileSet
    Filter the files from a file set based on a predicate function:
    # Includes all regular default.nix files from the current directory
    fileFilter (file: file.name == "default.nix" && file.type == "regular") ./.

This work is sponsored by Antithesis

Things done

  • Docs
  • Tests

@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label Oct 10, 2023
@infinisil infinisil changed the title lib.fileset.fileFilter: init lib.fileset.fileFilter: init Oct 10, 2023
@infinisil infinisil mentioned this pull request Oct 10, 2023
7 tasks
@infinisil infinisil force-pushed the fileset.fileFilter branch 2 times, most recently from 377fbd3 to 43f5dc3 Compare October 10, 2023 17:30
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Oct 10, 2023
type = subtree;
# To ensure forwards compatibility with more arguments being added in the future,
# adding an attribute which can't be deconstructed :)
"lib.fileset.fileFilter: The predicate function passed as the first argument must be able to handle extra attributes for future compatibility. If you're using `{ name, file }:`, use `{ name, file, ... }:` instead." = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, nice one!

lib/fileset/tests.sh Outdated Show resolved Hide resolved
[b]=1
[c/a]=1
)
# Note that union evaluates the first argument first if necessary, that's why we can use ./c/a here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Note that union evaluates the first argument first if necessary, that's why we can use ./c/a here
# Note that union evaluates the first argument first if necessary. That's why we can use ./c/a here
Suggested change
# Note that union evaluates the first argument first if necessary, that's why we can use ./c/a here
# Note that union evaluates the first argument first if necessary, so that's why we can use ./c/a here

@roberth roberth merged commit 185acbc into NixOS:master Oct 24, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants